class Solution
{
public:
    int MLS(vector<int>& arr)
    {
        int n = arr.size();
        sort(arr.begin(), arr.end());
        int ret = 1, len = 1;
        for (int i = 1; i < n; i++)
        {
            if (arr[i - 1] + 1 == arr[i])
                len++;
            else if (arr[i - 1] == arr[i])
                continue;
            else
            {
                len = 1;
                continue;
            }
            ret = max(ret, len);
        }

        return ret;
    }
};